package it.av.training.rest.service.web;

import it.av.training.rest.models.json.JSONResponse;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.wordnik.swagger.annotations.ApiOperation;

/**
 * Controller misc
 * 
 * @author alessandro vincelli
 * 
 */
@Controller
@RequestMapping(value = "/misc")
public class MiscController {

    private static Logger logger = Logger.getLogger(MiscController.class);
    @Autowired
    @Qualifier("messageSource")
    private ReloadableResourceBundleMessageSource messages;

    /**
     * @param user
     * @return added user
     */
    @ApiOperation(value = "Ping", notes = "Uses to test the client", responseClass = "JSONResponse")
    @RequestMapping(value="/ping", method = { RequestMethod.GET })
    public JSONResponse ping(HttpServletRequest request) {
        JSONResponse response = new JSONResponse(JSONResponse.SUCCESS, "000", "pong");
        logger.info("ping from: " + request.getRemoteAddr());
        return response;
    }
}
